package com.wise.site.widget;

import com.wise.site.R;

import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * 导航条单元view
 * 
 * @author huangyue
 * 
 *         2012-9-18
 */
public class IndexBarItemView extends LinearLayout {
	private boolean isHeadline;
	private TextView text;

	public IndexBarItemView(Context context, boolean headline) {
		super(context);
		setGravity(Gravity.CENTER);
		text = (TextView) inflate(context, R.layout.gallery_item, null);
		isHeadline = headline;
		if (headline) {
			text.setTextColor(0xffc3ff4e);
		}
		addView(text);
		setBackgroundResource(R.drawable.index_normal_bg);
	}
	
	public void setTextColor(int color) {
		text.setTextColor(color);
	}
	
	public void setText(String text) {
		this.text.setText(text);
	}

	/**
	 * 设置是否选中
	 * 
	 * huangyue 2012-9-18
	 */
	public void setSelect(boolean selected) {
		if (isHeadline) {
			text.setTextColor(0xffc3ff4e);
		}

		if (selected) {
			setBackgroundResource(R.drawable.index_selected_bg);
		} else {
			setBackgroundResource(R.drawable.index_normal_bg);
		}
	}

	public boolean isHeadline() {
		return isHeadline;
	}

	public void setHeadline(boolean isHeadline) {
		this.isHeadline = isHeadline;
	}

}
